//
//  DKAuthPanCardSubmitView.m
//  DanKU
//
//  Created by 吴斌 on 2023/12/6.
//

#import "DKAuthPanCardSubmitView.h"
@interface DKAuthPanCardSubmitView()
@property (nonatomic, weak)zhPopupController * dk_AuthStartAlertViewPop;
@property (nonatomic,strong)DKAuthPanCardSubmitView *dk_AuthPanCardSubmitView;
@property (nonatomic, strong)UIImageView * dk_AuthPanCardSubmitImgView;
@property (nonatomic, strong)UILabel * dk_AuthPanCardSubmitLab;
@property (nonatomic, copy)void(^DissAuthPanCardSubmitBlock)(void);
@end
@implementation DKAuthPanCardSubmitView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.clearColor;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UIView *dk_AuthPanCardSubmitBgView = [[UIView alloc] init];
    dk_AuthPanCardSubmitBgView.backgroundColor = DK_HexA(@"#000000",0.7);
    dk_AuthPanCardSubmitBgView.layer.cornerRadius = DK_IsWidthScale(18);
    [self addSubview:dk_AuthPanCardSubmitBgView];
    [dk_AuthPanCardSubmitBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self);
        make.width.equalTo(@(DK_IsWidthScale(191.71)));
        make.height.equalTo(@(DK_IsWidthScale(126)));
    }];
    self.dk_AuthPanCardSubmitImgView = [[UIImageView alloc] init];
    self.dk_AuthPanCardSubmitImgView.userInteractionEnabled = YES;
    [dk_AuthPanCardSubmitBgView addSubview:self.dk_AuthPanCardSubmitImgView];
    [self.dk_AuthPanCardSubmitImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(@(DK_IsWidthScale(26)));
        make.width.equalTo(@(DK_IsWidthScale(35)));
        make.height.equalTo(@(DK_IsWidthScale(35)));
    }];
    self.dk_AuthPanCardSubmitLab = [[UILabel alloc] init];
    self.dk_AuthPanCardSubmitLab.textColor = DK_Hex(@"#FFFFFF");
    self.dk_AuthPanCardSubmitLab.font = DK_FONT_Bold(13);
    self.dk_AuthPanCardSubmitLab.textAlignment = NSTextAlignmentCenter;
    [dk_AuthPanCardSubmitBgView addSubview:self.dk_AuthPanCardSubmitLab];
    [self.dk_AuthPanCardSubmitLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.dk_AuthPanCardSubmitImgView.mas_bottom).offset(DK_IsWidthScale(19));
        make.height.equalTo(@(DK_IsWidthScale(18)));
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(-DK_IsWidthScale(0)));
    }];
}
- (void)dissAuthPanCard{
    if(self.DissAuthPanCardSubmitBlock){
        [self.dk_AuthStartAlertViewPop dismiss];
        self.DissAuthPanCardSubmitBlock();
    }
}
+ (void)dk_ShowAuthPanCardSubmitView:(BOOL)isScuess withAlertView:(UIView *)alertView dissAuthPanCardSubmit:(void(^)(void))dissAuthPanCardSubmitBlock{
    WeakSelf(self)
    DKAuthPanCardSubmitView * dk_AuthPanCardSubmitView = [[DKAuthPanCardSubmitView alloc] init];
    zhPopupController * sureAuthStartCtrl = [[zhPopupController alloc] initWithView:dk_AuthPanCardSubmitView size:CGSizeMake(DK_SCREEN_W, DK_SCREEN_H)];
    dk_AuthPanCardSubmitView.DissAuthPanCardSubmitBlock = dissAuthPanCardSubmitBlock;
    sureAuthStartCtrl.presentationStyle = zhPopupSlideStyleTransform;
    sureAuthStartCtrl.layoutType = zhPopupLayoutTypeCenter;
    sureAuthStartCtrl.presentationTransformScale = 0.56;
    sureAuthStartCtrl.dismissonTransformScale = 0.56;
    sureAuthStartCtrl.dismissOnMaskTouched = NO;
    dk_AuthPanCardSubmitView.dk_AuthStartAlertViewPop = sureAuthStartCtrl;
    [sureAuthStartCtrl showInView:alertView completion:^{
        if(isScuess){
            dk_AuthPanCardSubmitView.dk_AuthPanCardSubmitImgView.image = DK_GetImage(@"dk_AuthCardScuessHead");
            dk_AuthPanCardSubmitView.dk_AuthPanCardSubmitLab.text = @"Submit successfully";
        }else{
            dk_AuthPanCardSubmitView.dk_AuthPanCardSubmitImgView.image = DK_GetImage(@"dk_AuthCardFailHead");
            dk_AuthPanCardSubmitView.dk_AuthPanCardSubmitLab.text = @"Submission failure";
        }
        [dk_AuthPanCardSubmitView performSelector:@selector(dissAuthPanCard) withObject:self afterDelay:1.5];
    }];
}
@end
